<?php
/* @var $this TeacherController */
/* @var $model Teacher */

$this->breadcrumbs=array(
	'Teachers'=>array('index'),
	'Manage',
);

$this->menu=array(
	array('label'=>'List Teacher', 'url'=>array('index')),
	array('label'=>'Create Teacher', 'url'=>array('create')),
);

Yii::app()->clientScript->registerScript('search', "
$('.search-button').click(function(){
	$('.search-form').toggle();
	return false;
});
$('.search-form form').submit(function(){
	$('#teacher-grid').yiiGridView('update', {
		data: $(this).serialize()
	});
	return false;
});
");
?>


<?php //echo CHtml::link('Advanced Search','#',array('class'=>'search-button')); ?>
<div class="search-form" style="display:none">
<?php //$this->renderPartial('_search',array(
	//'model'=>$model,
//)); ?>
</div><!-- search-form -->

<?php $this->widget('zii.widgets.grid.CGridView', array(
	'id'=>'teacher-grid',
		'summaryText'=>'แสดงรายการที่ {start} - {end} จากทั้งหมด {count} รายการ',
	'dataProvider'=>$model->search('teacher'),
	'filter'=>$model,
	'columns'=>array(
		array(
		'header'=>'รหัสอาจารย์',
		'value'=>'$data->user_id',
		'htmlOptions'=>array('width'=>'90px'),
		'filter'=>CHtml::activetextField($model,'user_id'),
		),
		//'active',
		array(
'header'=>'ชื่ออาจารย์',
				'value'=>'$data->prefix->prefix_name.$data->name." ".$data->surname',		
),
			array(
					'header'=>'โครงการ',
					'value'=>'($data->teacher)?$data->teacher->projectCount:""',
			),
	array(
		'header'=>'คณะกรรมการ',
		'value'=>'($data->teacher)?$data->teacher->commitCount:""',
	),

		//'email',
		//'phone',
		array(
		'class'=>'CButtonColumn',
		'header'=>'รายละเอียด',
		'template'=>'{project} {commit}',
		'buttons'=>array(
			'project' => array
				(
						'label'=>'โครงการที่รับผิดชอบ',
						'imageUrl'=>Yii::app()->request->baseUrl.'/images/doc.png',
						'url'=>'Yii::app()->createUrl("teacher/listProject", array("tid"=>$data->user_id))',
				),
				'commit' => array
				(
						'label'=>'คณะกรรมการสอบ',
						'imageUrl'=>Yii::app()->request->baseUrl.'/images/person.png',
						'url'=>'Yii::app()->createUrl("teacher/commitProject", array("tid"=>$data->user_id))',
				),
		),
),
	),
)); ?>
